//
//  LBBannerViewController.m
//  LbAdDemo
//
//  Created by SX on 2021/9/18.
//

#import "LBBannerViewController.h"
#import <LbAdSdk/ADv.h>
#import "Config.h"

@interface LBBannerViewController () <BannerDelegate>
@property (nonatomic, strong) BannerAD* banerAD;
@end

@implementation LBBannerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showAD];
}

- (void)showAD{
    BannerConfiguration *config = [[BannerConfiguration alloc] init];
    config.ADFrame = CGRectMake(.0f, 200.0f, CGRectGetWidth(self.view.bounds), 100.0f);
    config.rootViewController = self;
    _banerAD = [ADv showBannerAD:LB_TEST_BANNER_ID containerView:self.view configuration:config delegate:self];
}

- (void)reloadAD{
    [_banerAD reload];
}


// MARK:-loading
- (void)didFailToLoadADWithPlacementID:(NSString *)placementID error:(NSError *)error {
    NSLog(@"LBBannerViewController::didFailToLoadADWithPlacementID:%@ error:%@",placementID,error);
}

- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"LBBannerViewController::didFinishLoadingADWithPlacementID:%@",placementID);
}


// MARK:-banner
-(void) bannerView:(UIView *)bannerView didShowAdWithPlacementID:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"LBBannerViewController::bannerView:didShowAdWithPlacementID:%@ extra: %@", placementID,extra);
}

-(void) bannerView:(UIView*)bannerView didClickWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"LBBannerViewController::bannerView:didClickWithPlacementID:%@ extra: %@", placementID,extra);
}

-(void) bannerView:(UIView*)bannerView didCloseWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"LBBannerViewController::bannerView:didCloseWithPlacementID:%@ extra: %@", placementID,extra);
}

-(void) bannerView:(UIView *)bannerView didAutoRefreshWithPlacement:(NSString *)placementID extra:(NSDictionary*)extra {
    NSLog(@"LBBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ extra: %@", placementID,extra);
}

-(void) bannerView:(UIView *)bannerView failedToAutoRefreshWithPlacementID:(NSString *)placementID error:(NSError *)error {
    NSLog(@"LBBannerViewController::bannerView:failedToAutoRefreshWithPlacementID:%@ error:%@", placementID, error);
}

-(void) bannerView:(UIView*)bannerView didTapCloseButtonWithPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {
    NSLog(@"LBBannerViewController::bannerView:didTapCloseButtonWithPlacementID:%@ extra: %@", placementID,extra);
}

@end
